<?php namespace simpleFlow\view;

use simpleFlow\Object as SFObject;
use simpleFlow\view\View as SFView;

/**
 * Manage template theme
 * @package simpleFlow
 * @subpackage view
 * @author Guilherme Fontenele
 */
class Theme extends SFObject
{
	/**
	 * @var array Theme configs
	 */
	public $arrTheme;
	/**
	 * @var string Theme name
	 */
	public $strName;
	/**
	 * @var SFView View object
	 */
	public $objView;
	
	/**
	 * Constructor
	 * @param string $strThemeName Theme name
	 * @param SFView $objView View object
	 */
	public function __construct($strThemeName,$objView)
	{
		require_once(SF_THEME_DIR.$strThemeName.'/theme.php');
		$this->strName				= $strThemeName;
		$this->objView				= $objView;
		$this->arrTheme				= $arrTheme;
		$this->objView->arrTheme	= $arrTheme; // assign var arrTheme to theme tpl
	}
	
	/**
	 * Display the view on screen
	 */
	public function show()
	{
		$_arrTemplateDir = $this->objView->getTemplateDir();
		$this->objView->setTemplateDir(SF_THEME_DIR.$this->strName.'/');
		$this->objView->display('index.tpl');
		$this->objView->setTemplateDir($_arrTemplateDir[0]);
	}
	
	/**
	 * Get a parameter
	 * @param string $var1 Attribute name
	 * @param string $var2 Second attribute name
	 * @return id Parameter of false, if attribute dont exists 
	 */
	public function getParam($var1,$var2 = null)
	{
		if($var2)
		{
			if(isset($this->arrTheme[$var1]) && isset($this->arrTheme[$var1][$var2]))
			{
				return $this->arrTheme[$var1][$var2];
			}else{
				return false;
			}
		}else{
			if(isset($this->arrTheme[$var1]))
			{
				return $this->arrTheme[$var1];
			}else{
				return false;
			}
		}
	}
}

?>